<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>九宫格红包</title>
    {php echo register_jssdk();}
    <meta charset="utf-8">
    <meta content="" name="description">
    <meta content="" name="keywords">
    <meta content="eric.wu" name="author">
    <meta content="telephone=no, address=no" name="format-detection">
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<link href="{php echo S_URL.'/images/style.css'}" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    var commonjspath = "{php echo S_URL.'/images'}";
</script>
<script src="{php echo S_URL.'/images/jquery-1.8.3.min.js'}" type="text/javascript"></script>
<script src="{php echo S_URL.'/images/common.js'}" type="text/javascript"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
<style>
.pop{ position: fixed;	top:0;	left:0;	width:100%;	height:100%;background:rgba(0, 0, 0, 0.7);	display:none;z-index:1000; padding-top:15%;}
.content .prize ul li .jiangpin{position: relative;}
.content .prize ul li .jiangpin span {position:absolute;width:100%; text-align:center;bottom:9px;left:0; font-size:12px;border-radius:0 0 10px 10px;background-color: rgba(196, 43, 43, 0.57);color:#fff;padding:5px 0;}
.lottery-unit img{width:100%;}
</style>
</head>
<body>
<!-- 添加用户 -->
<div id="adduser" class="pop" style="display:none;">
    <div class="promptbox">
        <div class="box"><h1>用户标题</h1>
            <div class="line"><img src="../addons/zofui_jgghb/static/images/line_yellow.png" width="100%" /></div>
            <div class="user">
                <form id="add_form">
                <div class="input"><input type="text" id="xm" name="xm" placeholder="姓名" /></div>
                <div class="input id">
                    <input type="text" id="tel" name="tel" placeholder="电话" />
                    <input type="hidden" name="act" value="add">
                    <input type="hidden" name="act_id" value="{$act_id}">
                    <input type="hidden" name="tomhash" value="{$tomhash}">
                    <input type="hidden" name="formhash" value="{$formhash}">
                </div>
                </form>
                <div class="but_con"  >
                    <button class="add_user_btn button_01 but">参加</button><button class="button_02 but"  onclick="document.getElementById('adduser').style.display='none';"  style="margin-left:18%">关闭</button>
                    <div class="clr"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="score" class="pop" style="display:none;">
    <div class="promptbox">
        <div class="box"><h1>标题2</h1>
            <div class="line"><img src="../addons/zofui_jgghb/static/images/line_yellow.png" width="100%" /></div>
            <div class="user">
                <form id="score_form">
                <div class="input"><input type="text" id="username" name="username" placeholder="{lang tom_weixin_jgg:place_username}" /></div>
                <div class="input id">
                    <input type="text" id="password" name="password" placeholder="{lang tom_weixin_jgg:place_password}" />
                    <input type="hidden" name="act" value="score">
                    <input type="hidden" name="zj_id" id="zj_id" value="0">
                    <input type="hidden" name="prize_id" id="prize_id" value="0">
                    <input type="hidden" name="act_id" value="{$act_id}">
                    <input type="hidden" name="user_id" value="{$uid}">
                    <input type="hidden" name="tomhash" value="{$tomhash}">
                    <input type="hidden" name="formhash" value="{$formhash}">
                </div>
                </form>
                <div class="but_con"  >
                    <button class="get_score_btn button_01 but">{lang tom_weixin_jgg:duihuan}</button><button class="button_02 but"  onclick="document.getElementById('score').style.display='none';"  style="margin-left:18%">{lang tom_weixin_jgg:close}</button>
                    <div class="clr"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--{if $showGuanzu == 1}-->    
<div id="mustguanzu"  class="pop" style="display:block;">
    <div class="promptbox">
        <div class="box"><h1>{lang tom_weixin_jgg:guanzu_title}</h1>
            <div class="line"><img src="../addons/zofui_jgghb/static/images/line_yellow.png" width="100%" /></div>
            <div class="user">
                <div class="text2">
                    {$guanzu_desc}
                    <div class="clr"></div>
                </div>
                <!--{if $mustGuanzu == 0}-->  
                <div class="but_con">
                    <button class="button_01" onclick="document.getElementById('mustguanzu').style.display='';">{lang tom_weixin_jgg:close}</button>
                    <div class="clr"></div>
                </div>
                <!--{/if}-->
            </div>
        </div>
    </div>
</div>
<!--{/if}-->
<div id="guanzu"  class="pop" style="display:none;">
    <div class="promptbox">
        <div class="box"><h1>关注</h1>
            <div class="line"><img src="../addons/zofui_jgghb/static/images/line_yellow.png" width="100%" /></div>
            <div class="user">
                <div class="text2">
                    {$guanzu_desc}
                    <div class="clr"></div>
                </div>
                <div class="but_con">
                    <button class="button_01" onclick="document.getElementById('guanzu').style.display='';">{lang tom_weixin_jgg:close}</button>
                    <div class="clr"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 中奖了 -->
<div id="zjl"  class="pop" onclick="document.getElementById('zjl').style.display='';document.location.reload();" style="display:none;">
    <div class="promptbox">
        <div class="box"><h1>恭喜中奖了</h1>
            <div class="line"><img src="../addons/zofui_jgghb/static/images/line_yellow.png" width="100%" /></div>
            <div class="user">
                <img  id="jpimg" src="{$shareLogo}"  width="45%" class="left"  />
                <div class="text" style="margin-left:50%; ">
                    <span  id="jptype">{lang tom_weixin_jgg:prize_8_title}</span><br />
                    <span id="jpname" >奖品名称</span><br />
                    <img  src="../addons/zofui_jgghb/static/images/cat_03.png" width="120"/>
                    <div class="clr"></div>
                </div>
                <div class="but_con"  >
                    <button class="button_01">关闭</button>
                    <div class="clr"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 没有中奖 -->
<div id="mzj"  class="pop" onclick="document.getElementById('mzj').style.display='';document.location.reload();" style="display:none;">
    <div class="promptbox">
        <div class="box"><h1>标题3</h1>
            <div class="line"><img src="../addons/zofui_jgghb/static/images/line_yellow.png" width="100%" /></div>
            <div class="user">
                <img src="../addons/zofui_jgghb/static/images/cat_02.png"  width="70" class="left"  />
                <div class="text">
                    <span id="ncz">没有中奖哦</span>
                    <div class="clr"></div>
                </div>
                <div class="but_con">
                    <button class="button_01">知道了</button>
                    <div class="clr"></div>
                </div>
            </div>
        </div>
    </div>
</div>
   
   

<div class="container" id="lottery">
    <div class="NO">
        <ul>
            <li class="lottery-unit lottery-unit-0"><span class="active"></span><img src="{php echo !empty($prizeinfo[0]['pic'])?tomedia($prizeinfo[0]['pic']):'../addons/zofui_jgghb/static/images/prize_00.png'}" /></li>
            <li class="lottery-unit lottery-unit-1"><span></span><img src="{php echo !empty($prizeinfo[1]['pic'])?tomedia($prizeinfo[1]['pic']):'../addons/zofui_jgghb/static/images/prize_00.png'}"/></li>
            <li class="lottery-unit lottery-unit-2"><span></span><img src="{php echo !empty($prizeinfo[2]['pic'])?tomedia($prizeinfo[2]['pic']):'../addons/zofui_jgghb/static/images/prize_00.png'}"/></li>
            <li class="lottery-unit lottery-unit-7"><span></span><img src="{php echo '../addons/zofui_jgghb/static/images/ths.png'}"/></li>
            <li><a><img src="../addons/zofui_jgghb/static/images/start.jpg" style="cursor:pointer;" /></a></li>
            <li class="lottery-unit lottery-unit-3"><span></span><img src="{php echo !empty($prizeinfo[3]['pic'])?tomedia($prizeinfo[3]['pic']):'../addons/zofui_jgghb/static/images/prize_00.png'}"/></li>
            <li class="lottery-unit lottery-unit-6"><span></span><img src="{php echo !empty($prizeinfo[6]['pic'])?tomedia($prizeinfo[6]['pic']):'../addons/zofui_jgghb/static/images/prize_00.png'}"/></li>
            <li class="lottery-unit lottery-unit-5"><span></span><img src="{php echo !empty($prizeinfo[5]['pic'])?tomedia($prizeinfo[5]['pic']):'../addons/zofui_jgghb/static/images/prize_00.png'}"/></li>
            <li class="lottery-unit lottery-unit-4"><span></span><img src="{php echo !empty($prizeinfo[4]['pic'])?tomedia($prizeinfo[4]['pic']):'../addons/zofui_jgghb/static/images/prize_00.png'}"/></li>
            <div class="clr"></div>
        </ul>
    </div>
    <img src="../addons/zofui_jgghb/static/images/bg.jpg" class="img"/>
</div>

<script type="text/javascript">


function score(zj_id,prize_id){
    $("#zj_id").val(zj_id);
    $("#prize_id").val(prize_id);
    document.getElementById('score').style.display='block';
}

var lottery={
    index:0,	
    count:0,	
    timer:0,	
    speed:1000,	
    times:0,	
    cycle:50,	
    prize:-1,	
    init:function(id){
        if ($("#"+id).find(".lottery-unit").length>0) {
            slottery = $("#"+id);
            sunits = slottery.find(".lottery-unit");
            this.obj = slottery;
            this.count = sunits.length;
            slottery.find(".lottery-unit-"+this.index).find('span').addClass("active");
        };
    },
    roll:function(){
        var index = this.index;
        var count = this.count;
        var lottery = this.obj;
        $(lottery).find(".lottery-unit-"+index).find('span').removeClass("active");
        index += 1;
        if (index>count-1) {
            index = 0;
        };
        $(lottery).find(".lottery-unit-"+index).find('span').addClass("active");
        this.index=index;
        return false;
    },
    stop:function(index){
        this.prize=index;
        return false;
    }
};

function roll(){
    lottery.times += 1;
    lottery.roll();
    if (lottery.times > lottery.cycle+10 && lottery.prize==lottery.index) {
        clearTimeout(lottery.timer);
        lottery.prize=-1;
        lottery.times=0;
        click=false;
        if(lottery.index<7){
            setTimeout('$("#zjl").show()',1300);
        }else{
            setTimeout('$("#mzj").show()',1300);
        }
    }else{
        if (lottery.times<lottery.cycle) {
            lottery.speed -= 10;
        }else if(lottery.times==lottery.cycle) {
            index = myindex;//Math.random()*(lottery.count)|0;
            lottery.prize = index;
        }else{
            if (lottery.times > lottery.cycle+10 && ((lottery.prize==0 && lottery.index==7) || lottery.prize==lottery.index+1)) {
                lottery.speed += 110;
            }else{
                lottery.speed += 20;
            }
        }
        if (lottery.speed<40) {
            lottery.speed=40;
        };
        lottery.timer = setTimeout(roll,lottery.speed);
    }
    return false;
}

var allTimes = 5;
allTimes = allTimes * 1;

var useTimes = '{php echo $usertimes}';
useTimes = useTimes * 1;

var zjStatus = 0;
zjStatus = zjStatus * 1;

var hadprize = '{php echo $hadprize}';
hadprize = hadprize * 1;


var click = false;
var flag = 1;
var myindex = 7;
var submintCjStatus = 0;
window.onload=function(){
    lottery.init('lottery');
    $("#lottery a").click(function(){
        if (click){
            return false;		
        }else{
            if(submintCjStatus == 1){
                return false;
            }
            if(useTimes >= allTimes) {
                $('#ncz').html("{php echo '次数用完，明天再来吧'}");
                $('#mzj').show();
                flag =0;
                return false;
            }
            if(hadprize ==1){
                $('#ncz').html("{php echo '你已经中过奖了'}");
                $('#mzj').show();
                flag =0;
                return false;				
			}
            if(zjStatus > 0) {
                $('#ncz').html('{$zjMessage}');
                $('#mzj').show();
                flag =0;
                return false;
            }
            submintCjStatus = 1;
            $.ajax({
                url : '{php echo $this->createMobileUrl('ajax',array('openid'=>$_W['openid']))}',
                type : "GET",
                data : {},
                dataType : "json",
                beforeSend : function(){
                    $('#zjl').hide();
                    $('#mzj').hide();
                },
                success : function(data){
				
                    submintCjStatus = 0;
                    if(data.prize == 1) {
                        $('#jpimg').attr("src","{php echo tomedia($prizeinfo[0]['pic'])}");
                        $('#jptype').html("{php echo '抽中'.$prizeinfo[0]['money'].'元'}");
                        $('#jpname').text("请返回公众号查收");
                        flag =data.status;
                        myindex = 0;
                    }else if(data.prize == 2) {
                        $('#jpimg').attr("src","{php echo tomedia($prizeinfo[1]['pic'])}");
                        $('#jptype').html("{php echo '抽中'.$prizeinfo[1]['money'].'元'}");
                        $('#jpname').text("请返回公众号查收");
                        flag =data.status;
                        myindex = 1;
                    }else if(data.prize == 3) {
                        $('#jpimg').attr("src","{php echo tomedia($prizeinfo[2]['pic'])}");
                        $('#jptype').html("{php echo '抽中'.$prizeinfo[2]['money'].'元'}");
                        $('#jpname').text("请返回公众号查收");
                        flag =data.status;
                        myindex = 2;
                    }else if(data.prize == 4) {
                        $('#jpimg').attr("src","{php echo tomedia($$prizeinfo[3]['pic'])}");
                        $('#jptype').html("{php echo '抽中'.$prizeinfo[3]['money'].'元'}");
                        $('#jpname').text("请返回公众号查收");
                        flag =data.status;
                        myindex = 3;
                    }else if(data.prize == 5) {
                        $('#jpimg').attr("src","{php echo tomedia($prizeinfo[4]['pic'])}");
                        $('#jptype').html("{php echo '抽中'.$prizeinfo[4]['money'].'元'}");
                        $('#jpname').text("请返回公众号查收");
                        flag =data.status;
                        myindex = 4;
                    }else if(data.prize == 6) {
                        $('#jpimg').attr("src","{php echo tomedia($prizeinfo[5]['pic'])}");
                        $('#jptype').html("{php echo '抽中'.$prizeinfo[5]['money'].'元'}");
                        $('#jpname').text("请返回公众号查收");
                        flag =data.status;
                        myindex = 5;
                    }else if(data.prize == 7) {
                        $('#jpimg').attr("src","{php echo tomedia($prizeinfo[6]['pic'])}");
                        $('#jptype').html("{php echo '抽中'.$prizeinfo[6]['money'].'元'}");
                        $('#jpname').text("请返回公众号查收");
                        flag =data.status;
                        myindex = 6;
                    }else if(data.prize == 8) {
                        $('#ncz').text("没有中奖哦");
                        flag =data.status;
                        myindex = 7;
                    }else {
                        $('#ncz').text("出错啦");
                        flag =data.status;
                        myindex = 7;						
                    }
					
                },				
                complete :function() {				
                    if(flag==1){
                        lottery.speed=100;
                        roll();
                        click=true;
                        return false;
                    }else{
                        $('#mzj').show();
                        myindex = 7;
                    }
                }
            });

        }
    });
};



var submintScoreStatus = 0;
$(".get_score_btn").click( function () { 
    var username = $("#username").val();
    var password = $("#password").val();
    if(submintScoreStatus == 1){
        return false;
    }
    if(username == ""){
        tusi("{lang tom_weixin_jgg:must_username}");
        return false;
    }
    if(password == ''){
        tusi("{lang tom_weixin_jgg:must_password}");
        return false;
    }
    submintScoreStatus = 1;
    $.ajax({
        type: "GET",
        url: "plugin.php?id=tom_weixin_jgg:ajax",
        dataType : "json",
        data: $('#score_form').serialize(),
        success: function(data){
            submintScoreStatus = 0;
            if(data.status == 1) {
                tusi("{lang tom_weixin_jgg:dh_error}");
                setTimeout(function(){document.location.reload();},1888);
            }else if(data.status == 100){
                tusi("{lang tom_weixin_jgg:up_error}");
                setTimeout(function(){document.location.reload();},1888);
            }else if(data.status == 200){
                tusi("{lang tom_weixin_jgg:dh_success}");
                setTimeout(function(){document.location.reload();},1888);
            }else{
                tusi("{lang tom_weixin_jgg:dh_error}");
                setTimeout(function(){document.location.reload();},1888);
            }
        }
    });
});

function checkMobile(s){
	var regu =/^[1][3|8|4|5][0-9]{9}$/;
	var re = new RegExp(regu);
	if (re.test(s)) {
		return true;
	}else{
		return false;
	}
} 

</script>

</body>
</html>